package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.entity.AreaPlatform;
import com.wuseguang.springcloud.service.AreaPlatformService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 运营管理平台->区级平台账号 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-08-12
 */
@RestController
@RequestMapping("/admin")
public class AreaPlatformController {


    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private AreaPlatformService areaPlatformServiceImpl;

    /**
     * 添加区级平台
     * @param areaPlatform
     * @return
     */
    @RequestMapping("/addAreaPlatform")
    public Result addAreaPlatform(RequestParameterWrapper request,AreaPlatform areaPlatform){
        String adminId = request.getParam("adminId");
        logger.info("添加区级平台");
        areaPlatform.setSchoolAdminId(Integer.valueOf(adminId));
        return areaPlatformServiceImpl.addAreaPlatform(areaPlatform);
    }


    /**
     * 修改区级平台
     * @param areaPlatform
     * @return
     */
    @RequestMapping("/updateAreaPlatform")
    public Result updateAreaPlatform(AreaPlatform areaPlatform){

        logger.info("修改区级平台");
        return areaPlatformServiceImpl.updateAreaPlatform(areaPlatform);
    }

    /**
     * 删除区级平台
     * @param id
     * @return
     */
    @RequestMapping("/delteAreaPlatform")
    public Result delteAreaPlatform(@RequestParam(value = "id") Integer id){
        logger.info("删除区级平台");
        return areaPlatformServiceImpl.delteAreaPlatform(id);
    }

    /**
     * 查询区级平台
     * @param request
     * @return
     */
    @RequestMapping("/findAreaPlatform")
    public Result findAreaPlatform(RequestParameterWrapper request,
                                    @RequestParam(value = "indexNo", required = false, defaultValue = "1") Integer indexNo,
                                    @RequestParam(value = "rows", required = false, defaultValue = "20") Integer rows){
        String adminId = request.getParam("adminId");
        String role = request.getParam("role");
        logger.info("查询区级平台");
        return areaPlatformServiceImpl.findAreaPlatform(adminId,role,indexNo,rows);
    }
}

